/**
 *  This file is part of AugeasWH.
 *
 *  AugeasWH. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AugeasWH. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AugeasWH.  If not, see <http://www.gnu.org/licenses/>.
 */

package cz.fit.vutbr.pis2012.augeaswh.control.whman.slot_stock_items;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.richfaces.component.SortOrder;

@ManagedBean
@SessionScoped
public class SlotStockItemSortingBean implements Serializable {

	private static final long serialVersionUID = 2424910485055323478L;

	private SortOrder slotOrder = SortOrder.unsorted;
	private SortOrder placingDateOrder = SortOrder.unsorted;
	private SortOrder amountOrder = SortOrder.unsorted;
	
	public void sortBySlot() {
		setPlacingDateOrder(SortOrder.unsorted);
		setAmountOrder(SortOrder.unsorted);
		setSlotOrder((getSlotOrder().equals(SortOrder.ascending)) ? SortOrder.descending : SortOrder.ascending);
	}
	
	public void sortByPlacingDate() {
		setSlotOrder(SortOrder.unsorted);
		setAmountOrder(SortOrder.unsorted);
		setPlacingDateOrder((getPlacingDateOrder().equals(SortOrder.ascending)) ? SortOrder.descending : SortOrder.ascending);
	}
	
	public void sortByAmount() {
		setSlotOrder(SortOrder.unsorted);
		setPlacingDateOrder(SortOrder.unsorted);
		setAmountOrder((getAmountOrder().equals(SortOrder.ascending)) ? SortOrder.descending : SortOrder.ascending);
	}

	public SortOrder getSlotOrder() {
		return slotOrder;
	}

	public void setSlotOrder(SortOrder slotOrder) {
		this.slotOrder = slotOrder;
	}

	public SortOrder getPlacingDateOrder() {
		return placingDateOrder;
	}

	public void setPlacingDateOrder(SortOrder placingDateOrder) {
		this.placingDateOrder = placingDateOrder;
	}

	public SortOrder getAmountOrder() {
		return amountOrder;
	}

	public void setAmountOrder(SortOrder amountOrder) {
		this.amountOrder = amountOrder;
	}
}
